<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class CreateTaskMember extends AbstractMigration
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function up(): void
    {
        $table = $this->table('task_member', ['id' => false, 'primary_key' => ['id'], 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '待办任务']);
        $table->addColumn('id', 'integer', ['identity' => true, 'signed' => false, 'limit' => 11, 'comment' => '主键ID'])
            ->addColumn('task_id', 'integer', ['signed' => false, 'limit' => 11, 'comment' => '任务ID'])
            ->addColumn('user_id','integer', ['signed' => false, 'limit' => 11, 'comment' => '任务执行人ID'])
            ->addColumn('status', 'integer', ['signed' => false, 'limit' => 4, 'comment' => '任务状态'])
            ->addColumn('updated', 'integer', ['null' => false, 'default' => 0, 'limit' => 11, 'signed' => false, 'comment' => '更新时间'])
            ->addColumn('created', 'integer', ['null' => false, 'default' => 0, 'limit' => 11, 'signed' => false, 'comment' => '创建时间']);
        $table->addIndex(['task_id'], ['name' => 'idx_task_id_index', 'type' => 'normal']);
        $table->create();
    }

    public function down()
    {
        $this->table('task_member')->drop()->save();
    }

}
